'use strict';
var util = {
    /**
     * 仪表盘
     * @param {图表编号} chartid 
     * @param {数据} data  [{ value: 50, name: '完成率' }]
     */
    readGauge: function (chartid, data, opt) {
        opt = opt || {};
        let opts = $.extend({}, { max: 100, min: 0, lineColor: [[0.2, '#228b22'], [0.8, '#48b'], [1, '#ff4500']] }, opt);
        var myChart = echarts.init(document.getElementById(chartid));
        let option = {
            tooltip: {
                formatter: "{b} : {c}"
            },
            series: [
                {
                    type: 'gauge',
                    detail: {
                        show: false,
                        formatter: '{value}'
                    },
                    min: opts.min,
                    max: opts.max,
                    axisLabel: {
                        show: false,//坐标的文本标签
                    },
                    axisLine: {
                        lineStyle: {
                            show: true,
                            color: opts.lineColor,
                            width: 30
                        }
                    },
                    title: {
                        offsetCenter: [0, '30%'],
                        fontSize: 16,
                        color: 'white',
                    },
                    data: data,
                }
            ]
        };

        myChart.setOption(option);
    },
};